<?php

/**
 * @Author:             wuchenge
 * @Date:               2025-03-04 19:48:55
 * @Last Modified by:   wuchenge
 */
namespace App\Requests;

class UserLoginRequest extends FormRequest
{
    public function rules()
    {
        return [
            'email'       => [
                'required',
                'email:rfc,dns',

            ],
            're_password' => [
                'required',
                function ($attribute, $value, $fail) {
                    if ($value !== $this->input('password')) {
                        $fail('两次密码不一致');
                    }
                },
            ],
            'password'    => [
                'required',
                'min:6',
                'max:20',

            ],
        ];
    }

    public function messages()
    {
        return [
            'email.required'    => '10101',
            'password.required' => '10102',
        ];
    }

    /**
     * @var array
     */
    public $scene = [
        'front.login.register' => ['email', 're_password', 'password'],
        'front.login.login'    => ['email', 'password'],
    ];
}
